<template>
  <div style="width: 100%">
    <el-row>
      <el-col :span="24" style="background-color: yellowgreen">
        <p style="font-size: 24px ;text-align: center; margin: 16px 0">进销存管理系统</p></el-col>
    </el-row>

    <div style="width: 100%;position: absolute;top: 0;left: 20px">
      <div v-if="loginUser == ''" style="margin-top: 20px">你好，请先
        <router-link to="/login" style="margin: 10px 0">登陆</router-link>
      </div>
      <div v-else style="margin: 20px 10px">欢迎光临，{{ loginUser.name }}
        <router-link to="/login" style="margin: 20px">退出</router-link>
      </div>

    </div>

    <el-row>
      <el-col :span="4" style="height: 790px ;background-color: #545c64">
        <el-menu
            active-text-color="green"
            background-color="green"
            class="el-menu-vertical-demo"
            default-active="2"
            text-color="#fff"
            @open="handleOpen"
            @close="handleClose"
        >
          <el-sub-menu index="1" :disabled="dd">
            <template #title>
              <el-icon>
                <location/>
              </el-icon>
              <span>资料管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="1-1" @click="$router.push('/supplier/supplier')">供应商管理</el-menu-item>
              <el-menu-item index="1-2" @click="$router.push('/client/client')">客户管理</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>

          <el-sub-menu index="2" :disabled="dd">
            <template #title>
              <el-icon>
                <location/>
              </el-icon>
              <span>采购管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="2-1" @click="$router.push('/buyer/buyerCar')">采购入库</el-menu-item>
              <el-menu-item index="2-2" @click="$router.push('/buyer/buyer')">采购信息查询</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>

          <el-sub-menu index="3" :disabled="dd">
            <template #title>
              <el-icon>
                <location/>
              </el-icon>
              <span>销售管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="3-1" @click="$router.push('/sell/sellCar')">销售出库</el-menu-item>
              <el-menu-item index="3-2" @click="$router.push('/sell/sell')">销售信息查询</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>

          <el-sub-menu index="4" :disabled="dd">
            <template #title>
              <el-icon>
                <location/>
              </el-icon>
              <span>库存管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="4-1" @click="$router.push('/product/product')">库存一览</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>

          <el-sub-menu index="5" :disabled="dd">
            <template #title>
              <el-icon>
                <location/>
              </el-icon>
              <span>统计信息</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="5-1" @click="$router.push('/stat/statSell')">销售统计</el-menu-item>
              <el-menu-item index="5-2" @click="$router.push('/stat/statMonthSell')">月销售统计</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>

          <el-sub-menu index="6" :disabled="dd">
            <template #title>
              <el-icon>
                <location/>
              </el-icon>
              <span>权限管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="6-1" @click="$router.push('/user/user')">用户管理</el-menu-item>
              <el-menu-item index="6-2" @click="$router.push('/user/role')">角色管理</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>


          <el-sub-menu index="7" :disabled="dd">
            <template #title>
              <el-icon>
                <location/>
              </el-icon>
              <span>个人信息管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="7-1" @click="$router.push('/user/pwd')">修改密码</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>

          <el-sub-menu index="8" :disabled="dd">
            <template #title>
              <el-icon>
                <location/>
              </el-icon>
              <span>日志信息</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="8-1" @click="$router.push('/log/log')">日志一览</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>
        </el-menu>
      </el-col>

      <el-col :span="20">
        <router-view/>
      </el-col>
    </el-row>
  </div>

</template>

<script>
import axios from "axios";

export default {

  data() {
    return {
      loginUser: {},
      grade: [],
      dd: true,
    }
  },
  methods: {
    getLoginUser() {
      axios.get("/project/user/getLoginUser").then(resp => {
        this.loginUser = resp.data;
        console.log(this.loginUser);
      })
      console.log(this.loginUser);
    },
    show() {
      if (this.loginUser.id == null) {
        this.dd = false;
      }
    },
  },
  created() {
    this.getLoginUser();
    this.show(this.loginUser);
  }
}


</script>

<style scoped>

</style>